#!/usr/bin/env bash
#########################################################################
# File Name   : FILENAME
# Author      : seadog
# mail        : seadog0514@163.com
# Version     : 0.1
# Created Time: DATETIME
#########################################################################

#
#
# Usage:

{
  set -euo pipefail
  export TZ="Asia/Shanghai"
  APP_ROOT=$(dirname "$(readlink -fm "$0")")
  cd "${APP_ROOT}"
}

# !!! flat if
ip link set {{ network_flat_ifname }} up
# add bridge (any name you like for [br-eth1])
ovs-vsctl add-br br-{{ network_flat_ifname }}
# add a port to the bridge
# replace [eth1] to your own environment
ovs-vsctl add-port br-{{ network_flat_ifname }} {{ network_flat_ifname }}
# map [physnet1] to the bridge (any name you like for [physnet1])
ovs-vsctl set open . external-ids:ovn-bridge-mappings=physnet1:br-{{ network_flat_ifname }}

# !!! create virtual network
# source /root/keystonerc
# projectID=$(openstack --insecure project list | grep service | awk '{print $2}')
# # create network named [sharednet1]
# openstack --insecure network create --project $projectID \
#   --share --provider-network-type flat --provider-physical-network physnet1 sharednet1

# # create subnet [10.0.0.0/24] in [sharednet1]
# openstack --insecure subnet create subnet1 --network sharednet1 \
#   --project $projectID --subnet-range 10.0.0.0/24 \
#   --allocation-pool start=10.0.0.200,end=10.0.0.254 \
#   --gateway 10.0.0.1 --dns-nameserver 10.0.0.10

# confirm settings
# openstack --insecure network list
# openstack --insecure subnet list
